#include <iostream>

using namespace std;

int apple[5005];
int lq[5005];
int main(){
    int n,s,a,b;
    cin >> n >> s;
    cin >> a >> b;
    for(int i = 0; i < n; i++){
        cin >> apple[i] >> lq[i];
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        int min = 1000;
        int min_idx = -1;
        for(int i = 0; i < n; i++){
            if((apple[i] <= b+a)&&(s >= lq[i])&&(lq[i] < min)){
                min = lq[i];
                min_idx = i;
            }
        }
        if(min_idx >= 0){
            s -= lq[min_idx];
            sum += 1;
            lq[min_idx] = 9999;
        }
        else{
            
            break;
        }
    }
    cout << sum;
}